package org.gap.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAdherentByAdhAffiliation", query = "select myAdherent from Adherent myAdherent where myAdherent.adhAffiliation = ?1"),
		@NamedQuery(name = "findAdherentByAdhCin", query = "select myAdherent from Adherent myAdherent where myAdherent.adhCin = ?1"),
		@NamedQuery(name = "findAdherentByAdhDateAffiliation", query = "select myAdherent from Adherent myAdherent where myAdherent.adhDateAffiliation = ?1"),
		@NamedQuery(name = "findAdherentByAdhDateAffiliationAfter", query = "select myAdherent from Adherent myAdherent where myAdherent.adhDateAffiliation > ?1"),
		@NamedQuery(name = "findAdherentByAdhDateAffiliationBefore", query = "select myAdherent from Adherent myAdherent where myAdherent.adhDateAffiliation < ?1"),
		@NamedQuery(name = "findAdherentByAdhId", query = "select myAdherent from Adherent myAdherent where myAdherent.adhId = ?1"),
		@NamedQuery(name = "findAdherentByAdhImmatriculation", query = "select myAdherent from Adherent myAdherent where myAdherent.adhImmatriculation = ?1"),
		@NamedQuery(name = "findAdherentByAdhPension", query = "select myAdherent from Adherent myAdherent where myAdherent.adhPension = ?1"),
		@NamedQuery(name = "findAdherentByAdhSom", query = "select myAdherent from Adherent myAdherent where myAdherent.adhSom = ?1"),
		@NamedQuery(name = "findAdherentByPrimaryKey", query = "select myAdherent from Adherent myAdherent where myAdherent.adhId = ?1"),
		@NamedQuery(name = "findAllAdherents", query = "select myAdherent from Adherent myAdherent") })
@Table(schema = "GAP", name = "ADHERENT")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "GAP_v2/org/gap/domain", name = "Adherent")
public class Adherent implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "ADH_ID", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer adhId;
	/**
	 */

	@Column(name = "ADH_CIN", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer adhCin;
	/**
	 */

	@Column(name = "ADH_IMMATRICULATION", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer adhImmatriculation;
	/**
	 */

	@Column(name = "ADH_AFFILIATION", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer adhAffiliation;
	/**
	 */
	@Temporal(TemporalType.DATE)
	@Column(name = "ADH_DATE_AFFILIATION")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar adhDateAffiliation;
	/**
	 */

	@Column(name = "ADH_PENSION", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer adhPension;
	/**
	 */

	@Column(name = "ADH_SOM", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer adhSom;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "ADH_TIERS", referencedColumnName = "TIE_TIERS", nullable = false) })
	@XmlTransient
	Tiers tiers;

	/**
	 */
	public void setAdhId(Integer adhId) {
		this.adhId = adhId;
	}

	/**
	 */
	public Integer getAdhId() {
		return this.adhId;
	}

	/**
	 */
	public void setAdhCin(Integer adhCin) {
		this.adhCin = adhCin;
	}

	/**
	 */
	public Integer getAdhCin() {
		return this.adhCin;
	}

	/**
	 */
	public void setAdhImmatriculation(Integer adhImmatriculation) {
		this.adhImmatriculation = adhImmatriculation;
	}

	/**
	 */
	public Integer getAdhImmatriculation() {
		return this.adhImmatriculation;
	}

	/**
	 */
	public void setAdhAffiliation(Integer adhAffiliation) {
		this.adhAffiliation = adhAffiliation;
	}

	/**
	 */
	public Integer getAdhAffiliation() {
		return this.adhAffiliation;
	}

	/**
	 */
	public void setAdhDateAffiliation(Calendar adhDateAffiliation) {
		this.adhDateAffiliation = adhDateAffiliation;
	}

	/**
	 */
	public Calendar getAdhDateAffiliation() {
		return this.adhDateAffiliation;
	}

	/**
	 */
	public void setAdhPension(Integer adhPension) {
		this.adhPension = adhPension;
	}

	/**
	 */
	public Integer getAdhPension() {
		return this.adhPension;
	}

	/**
	 */
	public void setAdhSom(Integer adhSom) {
		this.adhSom = adhSom;
	}

	/**
	 */
	public Integer getAdhSom() {
		return this.adhSom;
	}

	/**
	 */
	public void setTiers(Tiers tiers) {
		this.tiers = tiers;
	}

	/**
	 */
	public Tiers getTiers() {
		return tiers;
	}

	/**
	 */
	public Adherent() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Adherent that) {
		setAdhId(that.getAdhId());
		setAdhCin(that.getAdhCin());
		setAdhImmatriculation(that.getAdhImmatriculation());
		setAdhAffiliation(that.getAdhAffiliation());
		setAdhDateAffiliation(that.getAdhDateAffiliation());
		setAdhPension(that.getAdhPension());
		setAdhSom(that.getAdhSom());
		setTiers(that.getTiers());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("adhId=[").append(adhId).append("] ");
		buffer.append("adhCin=[").append(adhCin).append("] ");
		buffer.append("adhImmatriculation=[").append(adhImmatriculation).append("] ");
		buffer.append("adhAffiliation=[").append(adhAffiliation).append("] ");
		buffer.append("adhDateAffiliation=[").append(adhDateAffiliation).append("] ");
		buffer.append("adhPension=[").append(adhPension).append("] ");
		buffer.append("adhSom=[").append(adhSom).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((adhId == null) ? 0 : adhId.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Adherent))
			return false;
		Adherent equalCheck = (Adherent) obj;
		if ((adhId == null && equalCheck.adhId != null) || (adhId != null && equalCheck.adhId == null))
			return false;
		if (adhId != null && !adhId.equals(equalCheck.adhId))
			return false;
		return true;
	}
}
